package com.aispeech.utils;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;

public class JsonUtils {
    public static ObjectMapper objectMapper() {
        ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
        return objectMapper;
    }

    public static  <T> T parse(String json, Class<T> clz) throws JsonProcessingException {
    	return objectMapper().readValue(json, clz);
	}

	public static  <T> T fastParse(String json, Class<T> clz) {
    	return JSON.parseObject(json, clz);
	}
}
